﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using TamTreSoSinh.DBContext;

namespace TamTreSoSinh.UC
{
    public partial class PartnerPart : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        private void LoadData()
        {
            DBTamTreEntities dbContext = new DBTamTreEntities();
            List<Partner> listPartner = dbContext.Partners.OrderBy(obj => obj.Priority).ToList();

            rptPartner.DataSource = listPartner;
            rptPartner.DataBind();
        }

        protected void rptPartner_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            Partner partner = (Partner)e.Item.DataItem;

            Image img = (Image)e.Item.FindControl("imgPartner");
            img.ImageUrl = partner.ImagePath;
        }
    }
}